package com.hnkywl.sts.dao.sys;

import com.hnkywl.sts.entity.organ.Dsgd;
import net.ruixin.orm.hibernate.SimpleHibernateTemplate;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 说明：
 * 包:        com.hnkywl.sts.dao.sys
 * 类描述:    菜单dao类
 * 修改备注: [说明本次修改内容]
 * 版本:        [v1.0]
 */
@Repository
public class DsgdDao extends SimpleHibernateTemplate<Dsgd, Long> {


    public List<Map> findCggsFromKh() {
        String sql = "select distinct g.id as \"id\",g.jc as \"jc\" from t_biz_kh kh left join t_sys_gsjg g on kh.cggs_id = g.id where g.type = 'nbgs'";
        List<Map> list = (List<Map>) createSQLQuery(sql).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
        return list.size() == 0 ? new ArrayList<Map>() : list;
    }

    public void deleteData() {
        String sql = "delete from t_sys_dsgd";
        this.executeSQL(sql);
    }

}
